package com.xiaode.controller.app.teacher.pair;

import com.jfinal.aop.Inject;
import com.jfinal.core.Controller;
import com.jfinal.core.Path;
import com.jfinal.ext.cors.EnableCORS;
import com.jfinal.kit.Ret;
import com.xiaode.common.model.Admin;
import com.xiaode.util.apidoc.annotation.Api;
import com.xiaode.util.apidoc.annotation.ApiOper;
import com.xiaode.util.apidoc.annotation.ApiPara;

import javax.validation.constraints.Size;

/**
 * 老师结对相关服务
 */
@Path("/tPair")
@Api("老师结对相关服务")
@EnableCORS
public class PairController extends Controller {

    @Inject
    private PairService service;
    
	/**
	 * 结对列表
	 */
	@ApiOper("结对列表")
	public void pairStudentPage(
			@ApiPara(value = "state", notes = "结对状态")Integer state,
			@Size @ApiPara(value = "page", notes = "页码")Integer page, 
			@Size @ApiPara(value = "limit", notes = "每页数量")Integer limit,
			@ApiPara(value = "keyWord",notes = "关键词")String keyWord) throws Exception{
		Admin admin = getAttr("user");
    	Ret ret = service.pairStudentPage(admin.getId(), state, page, limit,keyWord);
    	renderJson(ret);
    }

	/**
	 * 查询解绑列表
	 */
	@ApiOper("解绑列表")
	public void cancelPairPage(	@ApiPara(value = "state", notes = "结对状态")Integer state,
								   @Size @ApiPara(value = "page", notes = "页码")Integer page,
								   @Size @ApiPara(value = "limit", notes = "每页数量")Integer limit,
								   @ApiPara(value = "keyWord",notes = "关键词")String keyWord)throws Exception{
		Admin admin = getAttr("user");
		Ret ret = service.cancelPairPage(admin.getId(), state, page, limit,keyWord);
		renderJson(ret);
	}

	/**
	 * 教师审核解绑
	 */
	@ApiOper("教师确认解绑")
	public void pairCancelConfirm(@Size @ApiPara(value = "pairId", notes = "结对id")Integer pairId,
								  @Size @ApiPara(value = "state", notes = "确认状态")Integer state)throws Exception{
		Admin admin = getAttr("user");
		Ret ret = service.pairCancelConfirm(admin, pairId, state);
		renderJson(ret);
	}

	/**
	 * 老师确认结对
	 */
	@ApiOper("老师确认结对")
	public void pairConfirm(
			@Size @ApiPara(value = "pairId", notes = "结对id")Integer pairId,
			@Size @ApiPara(value = "state", notes = "确认状态（1申请，2通过，3拒绝）")Integer state) throws Exception{
		Admin admin = getAttr("user");
    	Ret ret = service.pairConfirm(admin, pairId, state);
    	renderJson(ret);
    }

	/**
	 * 获得教师绑定的学生的年级班级
	 */
	@ApiOper("获得教师绑定的学生的年级班级")
	public void findStuClassInfo(){
		Admin admin = getAttr("user");
		Ret ret = service.findStuClassInfo(admin.getId());
		renderJson(ret);
	}

//	/**
//	 * 查询需要绑定页面需要审核的数量
//	 */
//	@ApiOper("查询需要绑定页面需要审核的数量")
//    public void findUncheckNumber(){
//		Admin admin = getAttr("user");
//		Ret ret = service.findUncheckNumber(admin.getId());
//		renderJson(ret);
//	}
}